package operation;

import book.BookList;

import java.util.Scanner;

public class Del implements IOPeration{
    @Override
    public void work(BookList bookList) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入要移除书的名字:");
        String name = sc.nextLine();
        for (int i = 0; i < bookList.getBookNum(); i++) {
            if(name.equals(bookList.getBooklist()[i].getName())) {
                int j = 0;
                for (j = i; j < bookList.getBookNum() - 1; j++) {
                    bookList.getBooklist()[j] = bookList.getBooklist()[j+1];
                }
                bookList.getBooklist()[j+1] = null;
                bookList.setBookNum(bookList.getBookNum()-1);
                System.out.println("该书以从书架移除！");
                return;
            }
        }
        System.out.println("书架上不存在该书");

    }
}
